'''
@author Aurelien Deharbe

This file is part of Cute-Client.

Cute-Client is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Cute-Client is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with Cute-Client.  If not, see <http://www.gnu.org/licenses/>.
'''

import sys
from cuteclient.csclient import CSClient

c = CSClient('localhost', 5000)
s = c.newSession("example04")

win = s.qs("QWidget() -> win")
box = s.qs("QVBoxLayout(" + win + ")")

btn1 = s.qs("QPushButton('button1') -> btn1")
btn2 = s.qs("QPushButton('button2') -> btn2")
btn3 = s.qs("QPushButton('button3') -> btn3")

s.qs(box + ".addWidget(<btn1>)")
s.qs(box + ".addWidget(<btn2>)")
s.qs(box + ".addWidget(<btn3>)")

def button_clicked(sender):
    print "button clicked !"
def quit(sender):
    sys.exit(0)
s.registerCallback("<btn1>", "clicked", button_clicked)
s.registerCallback("<btn3>", "clicked", quit)

s.qs(win + ".show()")
s.mainloop()
